package typechecker.ast.type;

import java.util.LinkedList;
import java.util.List;

import typechecker.ast.Context;

public class TypeConstructorApplication extends TypeExpression{
	private TypeConstructor cons;
	private List<TypeExpression> params;
	
	
	public TypeConstructorApplication(TypeConstructor cons,List<TypeExpression> params) {
		this.cons = cons;
		this.params = params;
	}

	
	public TypeConstructor getCons() {
		return cons;
	}
	
	public List<TypeExpression> getParams() {
		return params;
	}

	@Override
	public String preetyPrint() {
		String ret = "[" +cons.preetyPrint();
		for( TypeExpression param : params )
			ret += " " + param.preetyPrint();
		ret += "]";
		return ret;
	}
	@Override
	public TypeExpression freshCopy(Context<TypeVariable> ctx) {
		List<TypeExpression> cloneParams = new LinkedList<TypeExpression>();
		for( TypeExpression param : params){
			cloneParams.add(param.freshCopy(ctx));
		}
		TypeConstructorApplication tca = new TypeConstructorApplication((TypeConstructor) this.cons.freshCopy(ctx), cloneParams);
		return tca;
	}
}
